package object07.sms;

import java.util.Objects;

public class Student {
    /*学生学号*/
    private int studentId;
    /*学生姓名*/
    private String name;
    /*语文成绩*/
    private int chineseScore;

    /*数学成绩*/
    private int mathScore;

    public Student(int studentId, String name, int chineseScore, int mathScore) {
        this.studentId = studentId;
        this.name = name;
        this.chineseScore = chineseScore;
        this.mathScore = mathScore;
    }

    public int getStudentId() {
        return studentId;
    }

    public void setStudentId(int studentId) {
        this.studentId = studentId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getChineseScore() {
        return chineseScore;
    }

    public void setChineseScore(int chineseScore) {
        this.chineseScore = chineseScore;
    }

    public int getMathScore() {
        return mathScore;
    }

    public void setMathScore(int mathScore) {
        this.mathScore = mathScore;
    }


    /*求学生的总成绩*/
    public int getTotalScore(){
        return chineseScore + mathScore;
    }

    /*展示学生的信息使用该方法:拼接所有的学生属性*/
    public String toString() {
        return studentId + " " + name + " " + chineseScore + " " + mathScore + " " + getTotalScore();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Student student)) return false;

        return Objects.equals(name, student.name);
    }
}
